import requests

class Login:
    def __init__(self):
         self.seeeion = requests.session()
    def login(self,name,password,code):
        self.seeeion.get(url="http://192.168.4.80/TinyShop_v1.7/index.php?con=simple&act=captcha&h=40&w=120&bc=3f4657&c=ffffff")
        url = "http://192.168.4.80/TinyShop_v1.7/index.php?con=admin&act=check"
        data = {"name":name,"password":password,"verifyCode":code}
        re = self.seeeion.post(url=url,data=data)
        # print(re.text)
        return re
    def add(self):
        add_url = "http://192.168.4.80/TinyShop_v1.7/index.php?con=goods&act=goods_edit"
        data1 = {"category_id":5, "type_id":0,"brand_id":0,"name":"zhihzang","tag_id":"hehe","goods_no":12121,"point":0,"sort":1,"unit":"%E4%BB%B6&imgs%5B%5D=data%2Fuploads%2F2014%2F05%2F04%2Ff81d28ad7c32504c0af3a8c44eec681e.jpg","img":"data%2Fuploads%2F2014%2F05%2F04%2Ff81d28ad7c32504c0af3a8c44eec681e.jpg","spec_items":6,"pro_no%5B%5D":"12121_1 &spec_item%5B%5D=45%3AL%3AL%3A","store_nums%5B%5D":100, "warning_line%5B%5D":2,"sell_price%5B%5D":10, "market_price%5B%5D":100,"cost_price%5B%5D":10,"weight%5B%5D":1000,"content":"", "seo_title":"","seo_keywords":"","seo_description":"", "sale_protection":""}
        r = self.seeeion.post(url=add_url,data=data1)
        print(r.text)
    def delete(self,id):
        delete_url="http://192.168.4.80/TinyShop_v1.7/index.php?con=goods&act=goods_del&id=%s"%id
        r = self.seeeion.get(delete_url)
        print(r.text)
    def addmember(self):
        url = 'http://192.168.4.80/TinyShop_v1.7/index.php?con=customer&act=customer_save'
        headers = {'Content-Type': 'application/x-www-form-urlencoded'}
        datas = {'name':'admin1','password':'123456','repassword':'123456',
                 'email':'2728320529%40qq.com','real_name':'xc','sex':'1',
                 'birthday':'2018-08-29','province':'440000','city':'442000',
                 'county':'910005','addr':'xx','phone':'15378196078','mobile':'15378196079','point':'0'}
        r = self.seeeion.post(url,data=datas,headers=headers)
        print(r.text)
if __name__ == "__main__":
    l = Login()
    l.login("admin","123456","aaaa")
    # l.add()
    # l.delete(26)
    l.addmember()